transform

old TransE-like models
git clone https://esimon.eu/repos/transform.git
Log | Files | Refs | README

point reflections.py (544B)


      1 #!/usr/bin/env python2
      2 
      3 from relations.base import *
      4 
      5 class Point_reflections(Base_relation):
      6     """ Point reflections class.
      7 
      8     This class has one parameter:
      9     P -- the centers of reflection
     10     """
     11     def __init__(self, rng, number, dimension, tag):
     12         """ Initialise the parameter. """
     13         parameters = [ ('P', (dimension,)) ]
     14         super(Point_reflections, self).__init__(rng, number, parameters, tag)
     15 
     16     def apply(self, inputs, p):
     17         """ Apply the given relations to a given input. """
     18         return 2*p - inputs